<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<link rel="stylesheet" href="../../../static/font-awesome-4.7.0/css/font-awesome.min.css" >
	<link rel="stylesheet" href="../../../static/vui/css/vui.css">

	<script type="text/javascript" src="../../../static/js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../../../static/js/jquery.cookie.min.js"></script>
	<script type="text/javascript" src="../../../static/layer/layer.js"></script>
	<script type="text/javascript" src="../../../static/vui/js/vui.js"></script>
	<script type="text/javascript" src="../../../static/js/common.js"></script>
</head>
<body>

<div id="formArea">

	<table class="table">
		<tr>
			<td class="required">科目名称</td>
			<td><input type="text" class="input" autocomplete="off" name="name"/></td>
		</tr>
		<tr>
			<td>科目类别</td>
			<td style="text-align: left;" align="left">
				<div class="radio-div">
					<input type="radio" value="1" name="type" checked="checked" id="type1">
					<label radio="radio" for="type1">收入</label>
				</div>
				<div class="radio-div" style="margin-left:20px;">
					<input type="radio" value="2" name="type" id="type2">
					<label radio="radio" for="type2">支出</label>
				</div>
			</td>
		</tr>
	</table>
</div>


<script>

var requestParams = app.getRequestParams();
$(function () {

	if(requestParams.id){
        $('#formArea').append('<input type="hidden" value="'+requestParams.id+'" name="id"/>');
        $('#formArea input[name="name"]').val(requestParams.name);
	}
});

app.getOkBtn().click(function(){
	if( !checkForm() ){
		return;
	}

	var url = 'resubject/insert';

	if(requestParams.id){
		url = 'resubject/update'
	}
	app.request({
		url:url,
		data:app.serializeForm(),
		success:app.actionSuccess_parent
	});


});

function checkForm(){
	var checkOptions = [
			{type:'input',name:'name',verify:[{type:'required'}]}
		];
	return app.checkForm(checkOptions);
}

</script>

</body>
</html>